package com.egg.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.egg.dao.BaseDao;
import com.egg.service.DeptService;
/**
 * @项目名称：egg   
 * @类名称：DeptServiceImpl   
 * @类描述：部门接口实现   
 * @创建人：wangchenyang
 * @创建时间：2012-9-3 下午3:27:41   
 * @修改人：
 * @修改时间：   
 * @修改备注：   
 * @version
 */
@Service
public class DeptServiceImpl implements DeptService {
	@Autowired
	BaseDao baseDao;
	
	@Override
	public List<Map<String, Object>> getAllDept() {
		String sql="SELECT * FROM EGG_DEPT";
		return baseDao.queryForList(sql);
	}

	@Override
	public List<Map<String, Object>> getOenDept(Object...obj) {
		String sql="SELECT * FROM EGG_DEPT WHERE ID=?";
		return baseDao.queryForList(sql, obj);
	}

	@Override
	public void addDept(Object... obj) {
		String sql="INSERT INTO EGG_DEPT(ID,DEPT_NAME,DEPT_DESCRIPTION,CREATE_TIME) VALUES(SEQ_EGG_DEPT.NEXTVAL,?,?,?)";
		baseDao.update(sql, obj);
	}

	@Override
	public void updateDept(Object... obj) {
		String sql="UPDATE EGG_DEPT SET DEPT_NAME=?,DEPT_DESCRIPTION=? WHERE ID=?";
		baseDao.update(sql, obj);
	}

	@Override
	public void deleteDept(Object... obj) {
		String sql="DELETE FROM EGG_DEPT WHERE ID=?";
		baseDao.update(sql, obj);
	}
	@Override
	public List<Map<String, Object>> getAllDeptForSelect() {
		String sql="SELECT ID AS DEPT_ID,DEPT_NAME FROM EGG_DEPT";
		return baseDao.queryForList(sql);
	}

}
